home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / Samples / Moofwars 1.02 / MoofWars Sprocket / •Headers / MoofWars.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-10  |  5.8 KB  |  197 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2. Moofwars.h
  3.  
  4. All of the standard application conditionals are defined in this header, along with
  5. all of the global variables declared by the game.
  6.  
  7. Author: Timothy Carroll
  8. Apple Developer Technical Support
  9. timc@apple.com
  10.  
  11. Modification History: 
  12.  
  13. 8/15/96        TMC     Initial Release
  14. 1/23/97        TMC     Conditionalized inclusion of MacHeadersPPC so that MrC will compile
  15. 1/23/97        TMC        Moved the Error Macros to an external file.
  16. 2/24/97        TMC        Moved conditional builds to an external file so that error macros can
  17.                     can be loaded separate from MoofWars.h
  18.  
  19. Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  20.  
  21. You may incorporate this sample code into your applications without
  22. restriction, though the sample code has been provided "AS IS" and the
  23. responsibility for its operation is 100% yours.  However, what you are
  24. not permitted to do is to redistribute the source as "DSC Sample Code"
  25. after having made changes. If you're going to re-distribute the source,
  26. we require that you make it clear in the source that the code was
  27. descended from Apple Sample Code, but that you've made changes.
  28.  
  29. *************************************************************************************/
  30.  
  31. #ifndef _MOOFWARS_
  32. #define _MOOFWARS_
  33.  
  34. #pragma once
  35.  
  36. #include <Quickdraw.h>
  37. #include <Palettes.h>
  38. #include <DrawSprocket.h>
  39.  
  40.  
  41. // 2/24/97
  42. // We now include the app conditionals from a separate file to prevent library files
  43. // from needing to specifically include our MoofWars header by name.
  44. #include "AppConditionals.h"
  45.  
  46.  
  47. // Moved the error macros out to the generic libraries, since I use them in other
  48. // projects.
  49. #include "Error Macros.h"    
  50.  
  51. /*********************************************************************************
  52.     OTHER NECESSARY HEADERS    
  53. *********************************************************************************/
  54. #include "TCommandTimer.h"
  55. #include "Scaling.h"
  56. #include "TGraphicCollection.h"
  57.  
  58. #if qUsingSound
  59. #include "Hollywood.h"
  60. #endif
  61.  
  62.  
  63. /*********************************************************************************
  64.     CONSTANTS    
  65. *********************************************************************************/
  66.  
  67.  
  68. // A few standard colors -- probably should use palette calls instead!
  69. const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF};
  70. const RGBColor kBlack = {0x0000, 0x0000, 0x0000};
  71. const RGBColor kDarkBlue = {0x0000,0x0000,0x7000};
  72. const RGBColor kLtGrey = {0xC000,0xC000,0xC000};
  73. const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF};
  74.  
  75. // The ResID of the application's color table.  All of my custom graphics routines use
  76. // an 8-bit color table and the sprite is encoded to use these colors.  The actual variable
  77. // to hold the color table is declared below.
  78.  
  79. enum {
  80.     kAppColorTableResID = 128
  81. };
  82.  
  83. // Various constants used to load the background tile and sprite graphics.
  84.  
  85. enum {
  86.     kGridResourceID = 500,
  87.     kShipResourceID = 1000,
  88.     kShotResourceID = 1001,
  89.     kEnemyResourceID = 1003
  90. };
  91.  
  92. // A few keys on the keyboard -- these are the ones I use right now, at least until I add
  93. // a real configuration dialog.
  94. enum
  95.  {
  96.      kEscapeKey = 0x35,
  97.      kPauseKey = 0x71,
  98.      
  99.      kUpKey = 0x7E,
  100.      kDownKey = 0x7D,
  101.      kLeftKey = 0x7B,
  102.      kRightKey = 0x7C,
  103.      
  104.      kPeriod = 0x2F,
  105.      kComma = 0x2B,
  106.      
  107.     kZKey = 0x06,
  108.     kXKey = 0x07,
  109.     kCKey = 0x08,
  110.     kVKey = 0x09,
  111.     kAKey = 0x00,
  112.      
  113.      kOne = 0x12,
  114.      kTwo = 0x13,
  115.      kThree = 0x14,
  116.      kFour = 0x15,
  117.      kZero = 0x1D
  118.  };
  119.  
  120. // Here's the actual mapping of the keys above to functions on the keyboard.  Change these
  121. // to change the key settings.
  122.  
  123. enum
  124.  {
  125.      kExitGame = kEscapeKey,
  126.      kDebugger = kPauseKey,
  127.      
  128.      kShipRotateLeft = kComma,
  129.      kShipRotateRight = kPeriod,
  130.      kShipApplyThrust = kUpKey,
  131.      kShipFireShot = kLeftKey,
  132.      kShipFireCluster = kRightKey,
  133.  
  134.     kEnemyRotateLeft = kZKey, 
  135.     kEnemyRotateRight = kXKey,
  136.     kEnemyThrustForward = kCKey,
  137.     kEnemyThrustBackward = kVKey, 
  138.     kEnemyFireShots = kAKey,
  139.  
  140.      kPlaySoundOne = kOne,
  141.      kPlaySoundTwo = kTwo,
  142.      kPlaySoundThree = kThree,
  143.      kPlaySoundFour = kFour,
  144.      kSoundToggle = kZero
  145.  };
  146. /*********************************************************************************
  147.     VARIABLES    
  148. *********************************************************************************/
  149.  
  150. // Holds the bounds of the playing field.
  151. extern WorldRect32            gWorldBounds;
  152.  
  153. // The main color table described above
  154. extern CTabHandle            gAppColorTable;
  155.  
  156. // Our draw sprocket context.
  157. extern DSpContextReference    gDrawContext;
  158.  
  159. // And a running total of the number of shots on the board.  We only keep this if
  160. // we are going to display this number on the screen.
  161. #if qShowTiming
  162. extern long                    gShotsOnBoard;
  163. #endif
  164.  
  165. // Holds the current state of the keyboard and other input devices when processing
  166. // the list of sprites.
  167. extern TInputState            gCommandKeys;
  168.  
  169. // A standard set of lookup tables in 16.16 fixed notation, so that we can quickly
  170. // do sin and cos.  We currently use 48 frames because thats easy to do from
  171. // Specular Infini-D.  360/48 = 7.5° per angle.
  172. extern long             gSinLookup[48];
  173. extern long             gCosLookup[48];
  174.  
  175. // Currently we are using the hollywood API, we'll either change to our own API or
  176. // remove sound code before shipping.
  177. #if qUsingSound
  178. extern SndReference gSounds[10];
  179. extern Boolean gPlayingSound;
  180. #endif 
  181.  
  182. // These hold all of the games graphics.  We export these because we can create
  183. // sprites faster if it is already known that the sprites are loaded.
  184. extern TGraphicCollection *gShipGraphics;
  185. extern TGraphicCollection *gEnemyGraphics;
  186. extern TGraphicCollection *gShotGraphics;
  187. /*********************************************************************************
  188.     FUNCTIONS    
  189. *********************************************************************************/
  190.  
  191. // This checks a particular key value against the 128-bit number returned by GetKeys.
  192. extern Boolean CheckKey (unsigned char *PtrToKeyMap, short theKey);
  193.  
  194.  
  195. #endif /* _MOOFWARS_ */
  196.  
  197.